package com.example.springLearning.part9.config;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.util.ErrorHandler;

public class TaskUtils {

    public static final ErrorHandler LOG_AND_SUPPRESS_ERROR_HANDLER = new LoggingErrorHandler();

    public static class LoggingErrorHandler implements ErrorHandler {
        private final Log log = LogFactory.getLog(LoggingErrorHandler.class);

        @Override
        public void handleError(Throwable t) {
            log.error("Unexpected error occurred in scheduled task", t);
        }
    }
}
